//统一管理接口
//引入二次封装的axios(带有请求，响应的拦截器)
import requests from './ajax'
import mockRequests from './mockAjax'

//三级联动接口
export const reqgetCategoryList = () =>
  requests({ url: 'product/getBaseCategoryList', method: 'get' })
// export const reqgetCategoryList = () =>requests.get(`/product/getBaseCategoryList`);

//获取banner(Home首页轮播图接口)
export const getBannerList = () => mockRequests.get('/banner')

//获取floor数据
export const getFloorList = () => mockRequests.get('/floor')

//获取搜索模块数据   /api/list  post方式   带参数
//需要一个空对象参数
export const getGetSerachInfo = (params) =>
  requests({ url: '/list', method: 'post', data: params })

//获取商品详情
export const getGoodsInfo = (skuId) =>
  requests({ url: `/item/${skuId}`, method: 'get' })

//添加购物车
export const addOrUpdateShopCar = (skuId, skuNum) =>
  requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

//获取购物车列表数据
export const getCardList = () =>
  requests({ url: '/cart/cartList', method: 'get' })

//删除商品
export const delCarGoods = (skuId) =>
  requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

//修改商品的选中状态
export const updateGoodsChecked = (skuId, isChecked) =>
  requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

//获取验证码
export const getCode = (phone) =>
  requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })

//用户注册 如果穿对象必须写dada
export const userRegister = (data) =>
  requests({ url: '/user/passport/register', data, method: 'post' })

//登录
export const userLogin = (data) =>
  requests({ url: '/user/passport/login', data, method: 'post' })

//获取用户信息
export const getUserInfo = () =>
  requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })

//退出登陆
export const logOut = () =>
  requests({ url: '/user/passport/logout', method: 'get' })

//获取用户地址信息
export const getUserAddressInfo = () =>
  requests({
    url: '/user/userAddress/auth/findUserAddressList',
    method: 'get',
  })

//获取订单交易页信息
export const getTradeInfo = () =>
  requests({ url: '/order/auth/trade', mehtod: 'get' })
